<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<link rel="stylesheet" href="../static/css/common/reset.min.css" />
		<link rel="stylesheet" href="../static/css/common/mui.min.css" />
		<link rel="stylesheet" type="text/css" href="../static/css/order/select_by.css?v=1" />
		<title>还款方式</title>
	</head>

	<body>
		<div class="body">
			<div class="header display">
				<span>还款金额</span>
				<span class="red"></span>
			</div>
			<div class="centent">
				<p>选择付款方式</p>
				<li class="helibao" style="display: none;">
					<lable onclick="alert(0)">绑卡支付<img src="../static/img/ic_info.png" id="fee_question"></lable>
					<span class="redio"></span>
				</li>
				<li class="fuyou" style="display: none;">
					<lable onclick="alert(1)">快捷支付<img src="../static/img/ic_info.png" id="fee_question"></lable>
					<span class="redio"></span>
				</li>
			</div>
			<div class="enter">
				<button onclick="go_pay(this)">去付款</button>
			</div>
		</div>
		<div class="alert display" style="display: none;">
			<div>
				<p class="title"></p>
				<p class="content"></p>
			</div>
		</div>
		<div id="myModal" style="display:none">
			<img src="../static/img/loading.png">
		</div>
	</body>
	<script src="../static/js/common.js?v=1"></script>
	<script src="../static/js/bridge.js"></script>
	<script src="../static/js/common/jquery.min.js"></script>
	<script type="text/javascript" src="../static/js/common/mui.min.js"></script>
	<script>
		var apiDomain = apiDomain();
		var webDomain = webDomain();
		var orderId = request['orderId'];
		var repayMoney = request['repayMoney'];
		var preclear = request['preclear'];
		$(".red").html(repayMoney + "元");
		var token = getToken();
		$.ajax({
			type: "post",
			url: apiDomain + "/order/repay_channel",
			async: true,
			dataType: 'json',
			data: {
				token: token
			},
			success: function(data) {
				if(data.status == 2000) {
					if(data.data.helibao == 1) {
						$('.helibao').find(".redio").addClass("bg_img");
						$('.helibao').show();
					} else {
						$('.fuyou').find(".redio").addClass("bg_img");
					};
					if(data.data.fuyou == 1) {
						$('.fuyou').show();
					};
					if(data.data.helibao == 0 && data.data.fuyou == 0) {
						$(".enter button").attr("disabled", true);
					}
				} else {
					$(".enter button").attr("disabled", true);
					mui.alert(data.message);
				};
			}
		});

		function go_pay(that) {
			$('#myModal').show();
			var ua = navigator.userAgent.toLowerCase();
			var index = $(".bg_img").parent().index();
			if(index == 1) {
				//合利宝还款
				var token = getToken();
				if(!token) {
					closeAndOpen(1);
					return;
				};
				$.ajax({
					url: apiDomain + "order/repay_text",
					type: "post",
					dataType: "json",
					data: {
						token: token,
						preclear: preclear,
						orderId: orderId
					},
					success: function(data) {
						if(data.status == 2000) {
							if(/android/.test(ua)) {
								skipPage(1, webDomain + "order/order_repay.html?repayNo=" + data.data);
							} else {
								window.location.href = "order_repay.html?repayNo=" + data.data;
							};
						} else {
							mui.alert(data.message);
						}
					}
				});
			};
			if(index == 2) {
				//富友还款
				if(/android/.test(ua)) {
					skipPage(1, webDomain + "order/select_fuyou.html?orderId=" + orderId + "&repayMoney=" + repayMoney + "&preclear=" + preclear);
				} else {
					window.location.href = "select_fuyou.html?orderId=" + orderId + "&repayMoney=" + repayMoney + "&preclear=" + preclear;
				};
			};
		};

		//选择还款方式
		$(".centent li").click(function() {
			$(".centent li").find(".redio").removeClass("bg_img");
			$(this).find(".redio").addClass("bg_img");
		});

		//提示语句
		var arr = [{
			title: "绑卡支付：",
			concent: "使用当前已绑定的银行卡进行支付", //合利宝
		}, {
			title: "快捷支付：",
			concent: "输入银行卡号以及预留手机号就可完成支付。" //富友
		}];

		function alert(num) {
			var ev = (event) ? event : ((window.event) ? window.event : "");
			ev.stopPropagation();
			$(".alert").stop().show();
			$(".alert .title").html(arr[num].title);
			$(".alert .content").html(arr[num].concent);
		};
		$(".alert").click(function() {
			$(this).stop().hide();
		});
	</script>

</html>